package day8;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

public class Test1 {
    public static void main(String[] args) throws Exception {
        // 反射获取类中的方法
        List<String> list = new ArrayList();
        list.add("余生");
        Class<?> zxf = Class.forName("java.util.ArrayList");
        Method add = zxf.getMethod("add", Object.class);
        Object arr = add.invoke(list, 22);

        for (Object s : list) {
            System.out.println(s);
        }
    }
}
